<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/resources/layout/templateInterno.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:rich="http://richfaces.org/rich">
    
    
	<ui:define name="body">
		<div class="form">
		<h:form id="formCadastroUsers">
		<h:panelGroup id="pgMensagens">
			  <div>
					<h:messages style="padding:5px" errorClass="errorMessage" infoClass="infoMessage"  />
			</div>
		</h:panelGroup>
		<div  class="field-clear"></div>
		  <t:fieldset id="idfsDadosPessoais"  >
		  <legend>Dados</legend>
		  
				
				 <div class="grid-4-12">
						<h:outputLabel  id="lbAuthorities"  class="form-lbl"  value="Perfil:"/>
						<h:selectOneMenu  converter="indexConverter" width="270" id="cbPerfis"  value="#{acessoBean.perfil}">
							  <f:selectItem itemLabel="Selecione..." itemValue=""/>
							   <t:selectItems value="#{acessoBean.listPerfis}" var="authority" itemLabel="#{authority.descricao}" itemValue="#{authority}"/>
							   <a4j:support ajaxSingle="true" event="onchange" action="#{acessoBean.limparFuncionalidadesSelecionada}"   reRender="pgFuncionalidades,panelAcessos,pgMensagens"></a4j:support>
						</h:selectOneMenu>					
				</div>
				<div class="field-clear"></div>
				<h:panelGroup id="pgFuncionalidades">
					<h:panelGroup rendered="#{acessoBean.perfil != null}">
						<div class="grid-3-12">
								<h:outputLabel  id="lbFuncionalidades"  class="form-lbl"  value="Perfil:"/>
								<h:selectOneMenu  converter="indexConverter" width="170" id="cbFuncionalidade"  value="#{acessoBean.funcionalidadeSelecionada}">
									  <f:selectItem itemLabel="Selecione..." itemValue=""/>
									   <t:selectItems value="#{acessoBean.funcionalidades}" var="func" itemLabel="#{func.nome}" itemValue="#{func}"/>
									   <a4j:support ajaxSingle="true" event="onchange" reRender="panelAcessos,pgMensagens"></a4j:support>
								</h:selectOneMenu>					
						</div>
					</h:panelGroup>
				</h:panelGroup>
				<div class="field-clear"></div>
				<h:panelGroup  id="panelAcessos" >
					<a4j:outputPanel rendered="#{acessoBean.funcionalidadeSelecionada != null}">
						<div class="grid-8-12" style="color: #999;">
							<h:outputLabel value="Tipos De Acessos:" styleClass="form-lbl" style="#padding-bottom: 8px;"/>
							<h:selectManyCheckbox  value="#{acessoBean.acessos}" id="tipoAcessos">
								<f:selectItems  value="#{acessoBean.listTipoAcessos}"/>
							</h:selectManyCheckbox>
						</div>
					</a4j:outputPanel>
				</h:panelGroup>
				 <div class="field-clear"></div>
				 
				
		 </t:fieldset>
		 <h:panelGroup id="pgBotaoSalvar" >
				 <div  class="grid-2-12">
						<a4j:commandButton styleClass="form-button" id="cbSalvar" value="Salvar" reRender="formCadastroVisitante,pgMensagens" action="#{acessoBean.salvar}" >	</a4j:commandButton>
				</div >
			</h:panelGroup>
	</h:form>
	</div>
	<t:saveState  value="#{acessoBean.perfil}"/> 	
	<t:saveState  value="#{acessoBean.listPerfis}"/> 	
	<t:saveState  value="#{acessoBean.funcionalidadeSelecionada}"/> 
	<t:saveState  value="#{acessoBean.funcionalidades}"/> 	
	<t:saveState  value="#{acessoBean.acessos}"/> 	
	<t:saveState  value="#{acessoBean.acesso}"/> 	 
	<t:saveState  value="#{acessoBean.listTipoAcessos}"/> 
	</ui:define>
</ui:composition>

